let apiApp = {
	login: '/login',
	users: '/users'
}

let apiProduct = {
	apply: '/apply',
	product:'/product'
}

let apiQuestion = {
	answerQuestion: '/question/answerQuestion',
	questionUser: '/question/questionUser',
	resultList: '/question/result',
	config: '/config'
}

// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作
const install = (Vue, vm) => {
	let login = (params = {}) => vm.$u.post(apiApp.login, params);
	let register = (params = {}) => vm.$u.post(apiApp.users, params); // 用户注册
	let updateUserInfo = (params = {}) => vm.$u.put(apiApp.users, params); // 修改用户信息
	let getUserDeatil = (params) => vm.$u.get(apiApp.users + '/' + params); // 获取用户详情
	let roundAnswerList = (params = {}) => vm.$u.get(apiQuestion.questionUser, params); // 查看上一轮次回答情况
	let resultList = (params = {}) => vm.$u.get(apiQuestion.resultList, params); // 查看上一轮次回答结果
	let getApplyDetail = (params) => vm.$u.get(apiProduct.apply + '/' + params); // 获取物品详情
	let getConfigDetail = (params) => vm.$u.get(apiQuestion.config + '/' + params); // 获取问卷配置详情
	let applyEvaluate = (params = {}) => vm.$u.post(apiProduct.apply, params); // 卖家申请评测
	let answerQuestion = (params = {}) => vm.$u.put(apiQuestion.answerQuestion, params); // 修改问卷
	let productList = (params = {}) => vm.$u.get(apiProduct.product, params); // 商品列表

	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {
		login,
		register,
		getUserDeatil,
		getApplyDetail,
		getConfigDetail,
		answerQuestion,
		applyEvaluate,
		roundAnswerList,
		resultList,
		updateUserInfo,
		productList
	};
}

export default {
	install
}
